<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;报表目录
  </div>
  <div class="work">

    <div class="top">
      <!-- first-input -->
      <!-- <input nz-input placeholder="唯一值" class="fm-input" [(ngModel)]="fs.queryObject['id:like']" /> -->
      <!-- <input nz-input placeholder="所属栏目ID" class="fm-input" [(ngModel)]="fs.queryObject['columnid:like']" /> -->

      <input nz-input placeholder="名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['name:like']" />
      <!-- <nz-input-number
                		placeholder="顺序" class="fm-input" [(ngModel)]="fs.queryObject['order']"
                    [nzMin]="1" [nzMax]="100" [nzStep]="1" >
                </nz-input-number> -->
      <!-- <input nz-input placeholder="报表定义" class="fm-input" [(ngModel)]="fs.queryObject['tablename:like']" /> -->
      <!-- <input nz-input placeholder="有效" class="fm-input" [(ngModel)]="fs.queryObject['valid:like']" /> -->
      <nz-year-picker [(ngModel)]="fs.queryObject['year']" (ngModelChange)='yearChange($event,1)' name="year" required
        #year="ngModel" class="fm-input" nzPlaceHolder="年份"></nz-year-picker>
      <!-- <nz-input-number
          [nzPlaceHolder]="'月份'" class="fm-input" [(ngModel)]="fs.queryObject['month']"
              [nzMin]="1" [nzMax]="12" [nzStep]="1" >
        </nz-input-number> -->
      <nz-select [(ngModel)]="fs.queryObject['month']" name="month" class="fm-input" #month="ngModel"
        (nzOpenChange)="monthDic.load('0')" [nzPlaceHolder]="'月份'">
        <nz-option *ngFor="let option of monthDic.datas" [nzLabel]="option.display" [nzValue]="option.code">
        </nz-option>
        <nz-option *ngIf="monthDic.isLoading" nzDisabled nzCustomContent>
          <i nz-icon type="loading"></i>加载中...
        </nz-option>
        <span *ngIf="!monthDic.isLoaded">
          <nz-option [nzLabel]="fs.er.monthName" [nzValue]="fs.er.month">
          </nz-option>
        </span>
      </nz-select>
      <!-- <input nz-input placeholder="父节点ID" class="fm-input" [(ngModel)]="fs.queryObject['pid:like']" /> -->
      <nz-button-group>
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
        </nz-button-group>
      </div>
    </div>

    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzShowPagination]="false" [nzFrontPagination]="false"
          [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing">
          <thead>
            <tr>
              <!-- <th>主键ID</th> -->
              <!-- <th>所属栏目ID</th> -->
              <th>名称</th>
              <!-- <th>顺序</th> -->
              <th>报表定义</th>
              <th>年份</th>
              <th>月份</th>
              <th>类型</th>
              <th>有效</th>
              <!-- <th>父节点ID</th> -->
              <th nzWidth="15%">操作</th>
            </tr>
          </thead>
          <tbody>
            <ng-template ngFor let-data [ngForOf]="fs.datas">
              <ng-template ngFor let-item [ngForOf]="fs.expandDataCache[data.id]">
                <tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)">
                  <td [nzIndentSize]="item.level*20" [nzShowExpand]="!item.leaf" [(nzExpand)]="item.expand"
                    (nzExpandChange)="fs.collapse(item,$event)">
                    <span class="form-edit" (click)="editReport(item)">{{item.name}}</span>
                  </td>
                  <!-- <td>{{data.id}}</td> -->
                  <!-- <td></td> -->
                  <!-- <td>{{item.order}}</td> -->
                  <td>{{item.tablenameName}}</td>
                  <td>{{item.year}}</td>
                  <td>{{item.month}}</td>
                  <td>{{item.reporttypeName}}</td>
                  <td>{{item.valid | boolReform}}</td>
                  <!-- <td>{{data.pid}}</td> -->
                  <td>
                    <a *ngIf="!item.leaf" (click)="fs.addRow(item)" class="form-button">新增子项</a>
                    <a nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntity(item)" nzPlacement="bottomRight"
                      class="form-button">删除</a>
                  </td>
                </tr>
              </ng-template>
            </ng-template>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <!-- <div nz-col [nzSpan]="12">
                  <nz-form-item>
                      <nz-form-label nzRequired class="form-label">所属栏目ID</nz-form-label>
                      <nz-form-control class="form-control" [nzValidateStatus]="columnid.invalid?'error':'success'" nzHasFeedback>
                          <input nz-input [(ngModel)]="fs.er.columnid"
                                name="columnid" required #columnid="ngModel" />
                      </nz-form-control>
                  </nz-form-item>
              </div> -->

          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label" [nzSpan]="5">类型</nz-form-label>
              <nz-form-control [nzSpan]="12" class="form-control"
                [nzValidateStatus]="reporttype.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.reporttype" name="reporttype" required required [nzAllowClear]="true"
                  #reporttype="ngModel" (nzOpenChange)="dicTypeDic.load('0')" [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of dicTypeDic.datas" [nzLabel]="option.display" [nzValue]="option.id">
                  </nz-option>
                  <nz-option *ngIf="dicTypeDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading"></i>加载中...
                  </nz-option>
                  <span *ngIf="!dicTypeDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.reporttypeName" [nzValue]="fs.er.reporttype">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">名称</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="name.invalid?'error':'success'" nzHasFeedback>
                <input nz-input [(ngModel)]="fs.er.name" name="name" required #name="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">序号</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'" nzHasFeedback>
                <nz-input-number [(ngModel)]="fs.er.order" name="order" required #order="ngModel" [nzMin]="1"
                  [nzMax]="100" [nzStep]="1" class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">是否有效</nz-form-label>
              <nz-form-control class="form-control">
                <nz-switch nzCheckedChildren="有" nzUnCheckedChildren="无" [(ngModel)]="fs.er.valid" name="valid"
                  #valid="ngModel">
                </nz-switch>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24" [hidden]="fs.er.reporttype != '1'">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">年份</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="reportYear.invalid?'error':'success'"
                nzHasFeedback>
                <nz-year-picker [(ngModel)]="fs.er.reportYear" class="form-control" name="reportYear" required
                  #reportYear="ngModel" nzPlaceHolder="年份"></nz-year-picker>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">月份</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="month.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.month" name="month" required required class="form-control"
                  #month="ngModel" (nzOpenChange)="monthDic.load('0')" [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of monthDic.datas" [nzLabel]="option.display" [nzValue]="option.code">
                  </nz-option>
                  <nz-option *ngIf="monthDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading"></i>加载中...
                  </nz-option>
                  <span *ngIf="!monthDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.monthName" [nzValue]="fs.er.month">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24" [hidden]="fs.er.reporttype != '1'">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label" [nzSpan]="5">数据定义</nz-form-label>
              <nz-form-control [nzSpan]="12" class="form-control"
                [nzValidateStatus]="tablename.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.tablename" name="tablename" required required #tablename="ngModel"
                  (nzOpenChange)="reportDic.load('0')" [nzPlaceHolder]="'请选择'">
                  <nz-option *ngFor="let option of reportDic.datas" [nzLabel]="option.display" [nzValue]="option.code">
                  </nz-option>
                  <nz-option *ngIf="reportDic.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading"></i>加载中...
                  </nz-option>
                  <span *ngIf="!reportDic.isLoaded">
                    <nz-option [nzLabel]="fs.er.tablenameName" [nzValue]="fs.er.tablename">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <!-- <div nz-row [nzGutter]="24">
              <div nz-col [nzSpan]="12">
                  <nz-form-item>
                      <nz-form-label nzRequired class="form-label">父节点ID</nz-form-label>
                      <nz-form-control class="form-control" [nzValidateStatus]="pid.invalid?'error':'success'" nzHasFeedback>
                          <input nz-input [(ngModel)]="fs.er.pid"
                                name="pid" required #pid="ngModel" />
                      </nz-form-control>
                  </nz-form-item>
              </div>
          </div> -->

        <div nz-row [nzGutter]="24" *ngIf="fs.er.reporttype != '1'">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary" [disabled]='order.invalid || name.invalid || reporttype.invalid '
              (click)="saveForm()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>

        <div nz-row [nzGutter]="24" *ngIf="fs.er.reporttype == '1'">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary"
              [disabled]='order.invalid || tablename.invalid || reportYear.invalid || name.invalid || month.invalid'
              (click)="saveForm()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>

      </form>

    </nz-modal>
  </div>
</div>